package com.example.demo.controller;



import com.example.demo.entity.SchoolStudentCourseRelationship;
import com.example.demo.entity.dto.MaxCourseDTO;
import com.example.demo.entity.dto.SchoolCourseDeleteDTO;
import com.example.demo.entity.vo.ResultVO;
import com.example.demo.service.SchoolStudentCourseRelationshipService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * (SchoolStudentCourseRelationship)表控制层
 *
 * @author makejava
 * @since 2022-07-30 17:18:31
 */
@RestController
@RequestMapping("/school_student_course_relationship")
public class SchoolStudentCourseRelationshipController{

    @Autowired
    SchoolStudentCourseRelationshipService schoolStudentCourseRelationshipService;

    @PostMapping("/delete")
    public ResultVO deleteCourse(@RequestBody SchoolCourseDeleteDTO schoolCourseDeleteDTO){
        System.out.println(schoolCourseDeleteDTO);

        schoolStudentCourseRelationshipService.deleteCourse(schoolCourseDeleteDTO);

        return ResultVO.ok();
    }

    @GetMapping("/select_grade")
    public ResultVO selectCourseGrade(){
        //System.out.println();
        return ResultVO.ok(schoolStudentCourseRelationshipService.selectCourseGrade());
    }

    @GetMapping("/max_grade")
    public ResultVO getMaxGrade(){
        SchoolStudentCourseRelationship schoolStudentCourseRelationship=new SchoolStudentCourseRelationship();
        schoolStudentCourseRelationship=schoolStudentCourseRelationshipService.selectMaxGrade();
        return ResultVO.ok(new MaxCourseDTO(schoolStudentCourseRelationship.getSno(),schoolStudentCourseRelationship.getCno()));
    }
}

